/*  dreic -- a compiler for Drei
 *
 *  $Id: ScannerTest.scala 2970 2006-10-16 09:57:51Z mihaylov $
 */

package dreic


/**
 * A small scanner test class; it reads in a file and prints out
 * the sequence of tokens.
 *
 * usage: scala dreic.ScannerTest <file.drei>
 */
object ScannerTest {
  import java.io.{FileInputStream, IOException}

  def main(args: Array[String]): Unit = {
    if (args.length != 1) {
      Console.println("usage: scala dreic.ScannerTest <file.drei>")
      System.exit(1)
    }
    try {
      val in = new FileInputStream(args(0))
      val scanner = new Scanner(in)
      while (scanner.token != Tokens.EOF) {
        Console.println(scanner.representation)
        scanner.nextToken
      }
      in.close()
    }
    catch {
      case e: IOException => Report.fail(e.getMessage())
    }
  }

}
